$line-height: 1.375;
:root {
    --code-bg-color: #282C34;
    --code-hl-bg-color: rgb(0 0 0 / 66%);
    --code-ln-color: #9E9E9E;
    --code-ln-wrapper-width: 3.5rem;
}

@keyframes blink {
    0%,
    100% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
}

.markdown-body {
    font-size: 15px;
    color: unset;
    background-color: transparent;
    .markdown-custom-link {
        margin-bottom: 5px;
        color: var(--el-color-primary);
        cursor: pointer;
    }
}

.markdown-it-container {
    position: relative;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    ul { list-style: disc; }
    ol { list-style: decimal; }

    // 打字机效果
    .markdown-typing {
        position: absolute;
        display: inline-block;
        width: 5px;
        height: 14px;
        color: #1a202c;
        content: '';
        background-color: currentcolor;
        transform: translate(4px, 2px) scaleY(1.3);
        animation: blink 0.6s infinite;
    }

    // 引用块
    .markdown-doc-link-quote {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 16px !important;
        height: 16px !important;
        margin-left: 2px;
        font-size: 10px;
        line-height: 14px;
        color: #485568 !important;
        vertical-align: text-bottom;
        background-color: #edeff1 !important;
        border-radius: 50%;
        transition: 0s;
        &:hover {
            color: #ffffff !important;
            background-color: var(--el-color-primary) !important;
        }
    }

    // 代码块
    code {
        padding: 0.25rem;
        margin: 0;
        font-size: 0.85em; 
        color: #476582;
        border-radius: 3px;
    }

    code[class*="language-"],
    pre[class*="language-"] {
        font-size: 1em;
        hyphens: none;
        line-height: 1.5;
        color: #cccccc;
        text-align: left;
        word-break: normal;
        word-wrap: normal;
        tab-size: 4;
        white-space: pre;
        background: none;
        word-spacing: normal; 
        &::-webkit-scrollbar {
            cursor: pointer;
            background-color: #1c1f24;
            border-bottom-right-radius: 6px;
        }
        &::-webkit-scrollbar-thumb {
            display: block;
            cursor: pointer;
            background-color: #545a63;
            border-radius: 12px;
            &:hover {
                background-color: #4b525b;
            }
        }
    }

    /* Code blocks */
    pre[class*="language-"] {
        padding: 1em;
        margin: 0;
        overflow: auto;
    }

    :not(pre) > code[class*="language-"],
    pre[class*="language-"] {
        background: #2d2d2d;
    }

    /* Inline code */
    :not(pre) > code[class*="language-"] {
        padding: 0.1em;
        white-space: normal;
        border-radius: 0.3em;
    }

    pre,
    pre[class*="language-"] {
        padding: 2.5rem 1.5rem 1.3rem;
        overflow: auto;
        line-height: $line-height;
        border-radius: 6px;
        code {
        padding: 0;
        color: #ffffff;
        overflow-wrap: unset;
        background-color: transparent !important;
        border-radius: 0;
        -webkit-font-smoothing: auto;
        -moz-osx-font-smoothing: auto;
        }
    }

    div[class*="language-"] {
        position: relative;
        background-color: var(--code-bg-color);
        border-radius: 6px;
        .code-copy-btn {
            position: absolute;
            top: 0.8em;
            right: 1rem;
            z-index: 3;
            font-size: 0.75rem;
            color: var(--code-ln-color);
            cursor: pointer;
        }

        &::before {
            position: absolute;
            top: 0.8em;
            left: 6em;
            z-index: 3;
            font-size: 0.75rem;
            color: var(--code-ln-color);
            content: attr(data-ext);
        }

        pre,
        pre[class*="language-"] {
            position: relative;
            z-index: 1;
            background: transparent !important;
        }

        &:not(.line-numbers-mode) {
            .line-numbers {
                display: none;
            }
        }

        &.line-numbers-mode {
            pre {
                padding-left: 1rem;
                margin-left: var(--code-ln-wrapper-width);
                vertical-align: middle;
            }

            .line-numbers {
                position: absolute;
                top: 0;
                width: var(--code-ln-wrapper-width);
                padding-top: 2.5rem;
                line-height: $line-height;
                color: var(--code-ln-color);
                text-align: center;
                counter-reset: line-number;
                .line-number {
                position: relative;
                z-index: 3;
                height: #{$line-height}em;
                user-select: none;
                    &::before {
                        font-size: 0.85em;
                        content: counter(line-number);
                        counter-increment: line-number;
                    }
                }
            }

            &::after {
                position: absolute;
                top: 0;
                left: 0;
                width: var(--code-ln-wrapper-width);
                height: 100%;
                content: "";
                border-right: 1px solid var(--code-hl-bg-color);
                border-radius: 6px 0 0 6px;
            }
        }
    }
}
